package com.movitech.mobile.cz.base.purchase.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.movitech.mobile.cz.base.common.license.LicenseUtil;
import com.movitech.mobile.cz.base.common.util.CommonConstants;
import com.movitech.mobile.cz.base.purchase.entity.WFlowFormStrategicProtocol;
import com.movitech.mobile.cz.base.purchase.entity.ext.ExtWFlowFormStrategicProtocol;
import com.movitech.mobile.cz.base.purchase.mapper.WFlowFormStrategicProtocolMapper;
import com.movitech.mobile.cz.base.purchase.mapper.ext.ExtWFlowFormStrategicProtocolMapper;
import com.movitech.mobile.cz.base.purchase.service.WFlowFormStrategicProtocolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Movitech Mobile
 * @since 2018-03-29
 */
@Service
public class WFlowFormStrategicProtocolServiceImpl extends ServiceImpl<WFlowFormStrategicProtocolMapper, WFlowFormStrategicProtocol> implements WFlowFormStrategicProtocolService {
    @Autowired
    private ExtWFlowFormStrategicProtocolMapper extWFlowFormStrategicProtocolMapper;

    @Override
    public List<ExtWFlowFormStrategicProtocol> getByFormId(String formId) {
        return extWFlowFormStrategicProtocolMapper.getByFormId(formId);
    }

    @Override
    public void deleteById(String id) {
        LicenseUtil.INSTANCE.validate();
        WFlowFormStrategicProtocol wFlowFormStrategicProtocol = new WFlowFormStrategicProtocol();
        wFlowFormStrategicProtocol.setId(id);
        wFlowFormStrategicProtocol.setDelFlag(CommonConstants.DEL_FLAG_DELETE);
        updateById(wFlowFormStrategicProtocol);
    }

    @Override
    public void updatePriceById(String id, Double price) {
        LicenseUtil.INSTANCE.validate();
        WFlowFormStrategicProtocol wFlowFormStrategicProtocol = new WFlowFormStrategicProtocol();
        wFlowFormStrategicProtocol.setId(id);
        wFlowFormStrategicProtocol.setStrategicPrice(price);
        updateById(wFlowFormStrategicProtocol);
    }
}
